﻿#include "FITKAbaAbstractInteraction.h"
#include "FITKAbaAbstractStep.h"
#include "FITKAbaStepManager.h"


bool Interface::FITKAbaAbstractInteraction::hasGetStepManager()
{
    if (m_stepManager != nullptr)
        return true;
    m_stepManager = this->getStepManager(this);
    if (m_stepManager == nullptr)
        return false;
    return true;
}

bool Interface::FITKAbaAbstractInteraction::copy(FITKAbstractDataObject *obj)
{
    FITKAbaAbstractInteraction* interaction = dynamic_cast<FITKAbaAbstractInteraction*>(obj);
    if (interaction == nullptr)
        return false;
    //libaojun @20240503
    FITKInteractionLocation::copy(obj);
//     _location1 = interaction->_location1;
//     _location2 = interaction->_location2;
    m_activeState = interaction->m_activeState;
    m_createdStepId = interaction->m_createdStepId;
    m_deactiveStepId = interaction->m_deactiveStepId;
    return true;
}

bool Interface::FITKAbaAbstractInteraction::isValidInCreatedStep()
{
    if (!this->hasGetStepManager())
        return true;
    FITKAbaAbstractStep* step = m_stepManager->getDataByID(m_createdStepId);
    if (step == nullptr)
        return true;
    if (step->isPerturbation())
        return false;
    return true;
}

bool Interface::FITKAbaAbstractInteraction::getActiveState() const
{
    return m_activeState;
}

void Interface::FITKAbaAbstractInteraction::setActiveState(bool stat)
{
    m_activeState = stat;
}
